#! /bin/sh

CUR=$(pwd)

export GWLIB_DIR=$CUR/gwlib
export SURBASIC_DIR=$CUR/surbasic

GW_VERSION=$(cat gateway/VERSION)
FUSE_VERSION=$(cat sur_fuse/VERSION)

export DICOM_DIR=$CUR

cd gateway/
./rpm/create_source_package.sh $GW_VERSION

cd $CUR
cd sur_fuse
./rpm/create_source_package.sh $FUSE_VERSION


cd ~/rpmbuild/SPECS
rm -fv ~/rpmbuild/RPMS/x86_64/surcloud-gateway-$GW_VERSION-1.el6.x86_64.rpm
rm -fv ~/rpmbuild/RPMS/x86_64/surcloud-hybrid-storage-$FUSE_VERSION-1.el6.x86_64.rpm

rpmbuild -bb surcloud-gateway.spec
rpmbuild -bb surcloud-hybrid-storage.spec

cd $CUR
cp -v ~/rpmbuild/RPMS/x86_64/surcloud-hybrid-storage-$FUSE_VERSION-1.el*.x86_64.rpm .
cp -v ~/rpmbuild/RPMS/x86_64/surcloud-gateway-$GW_VERSION-1.el*.x86_64.rpm .  
